<%-- 
    Document   : index
    Created on : Sep 29, 2013, 10:37:20 AM
    Author     : DH
--%>

<%@page import="utils.CommonConstants"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Home Page</title>
    </head>
    <body>
        <h1>Newest Products</h1>
        <c:if test="${empty USER}">
            <form action="LoginServlet">
                Username <input type="text" name="txtUser" value="" /><br/>
                Password <input type="password" name="txtPass" value="" /><br/>
                <input type="submit" value="Login" name="action"/>
            </form>
        </c:if>
        <c:if test="${not empty USER}">
            Welcome, ${FULLNAME} <br/>
            <a href="LoginServlet?action=Logout">[Logout]</a> <br/>
            <a href="ProductProcessServlet?action=manage">Manage products</a><br/>
            <a href="<%=CommonConstants.SERVLET_PROCESS_ORDER %>?action=Show&stt=<%=CommonConstants.STATUS_ORDER_WAITING %>">Manage orders</a><br/>
        </c:if>
        <c:if test="${not empty PROD}">
            <table border="1">
                <thead>
                    <tr>
                        <th>No.</th>
                        <th>Id</th>
                        <th>Product Name</th>
                        <th>Category</th>
                        <th>Price</th>
                        <th>Image Path</th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach var="prod" items="${PROD}" varStatus="counter">
                        <tr>
                            <td>${counter.count}</td>
                            <td>${prod.id}</td>
                            <td>${prod.productName}</td>
                            <td>${prod.productCategory}</td>
                            <td>${prod.price}</td>
                            <td>${prod.imagePath}</td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
        </c:if>
    </body>
</html>
